/**
 * 
 */
package fr.univnantes.lina.mlnlp.models.ml;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author hernandez
 *
 */
public class Instance {

		private String label;
		private List<Feature> featureList;
		
		/**
		 * @return the size (number of features)
		 */
		public int getSize() {
			return this.featureList.size();
		}
		
		/**
		 * @return the label
		 */
		public String getLabel() {
			return label;
		}


		/**
		 * @param label the label to set
		 */
		public void setLabel(String label) {
			this.label = label;
		}


		/**
		 * @return the features
		 */
		public List<Feature> getFeatureList() {
			return featureList;
		}


		/**
		 * @param features the features to set
		 */
		public void setFeatures(List<Feature> featureList) {
			this.featureList = featureList;
		}

		/**
		 * @param add feature
		 */
		public void addFeature(Feature feature) {
			this.featureList.add(feature);
		}

		/**
		 * @param add feature
		 */
		/*public void addFeature(String name, Alphabet alphabet, Object value) {
			Feature aFeature = new Feature(name, alphabet, value);
			this.featureList.add(aFeature);
		}*/
		
		/**
		 * @param add feature
		 */
		public void addFeature(String name) {
			Feature aFeature = new Feature(name);
			this.featureList.add(aFeature);
		}
		
		/**
		 * @param add feature
		 */
		public void addFeature(String name, Object value) {
			Feature aFeature = new Feature(name, value);
			this.featureList.add(aFeature);
		}

		/**
		 * From a list of names, create features with the names and assign them the default value
		 * @param add 
		 */
		public void addFeatures(List<String> featureNameList) {
			Iterator<String> featureNameListIterator = featureNameList.iterator();
			while (featureNameListIterator.hasNext()) {
				String featureName = featureNameListIterator.next();
				this.addFeature(featureName);
			}
		}
		
		/**
		 * 
		 */
		public Instance() {
			super();
			// TODO Auto-generated constructor stub
			label = "";
			featureList = new ArrayList<Feature>();
		}
		
		/**
		 * 
		 * @param label
		 * @param features
		 */
		public Instance(String label, List<Feature> featureList) {
			super();
			this.label = label;
			this.featureList = featureList;
		}
		
		
		
}
